package com.pay.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;

/**
 * @author zhouyihe
 * @ClassName RabbitMQConfig
 * @qq 1552951165
 */
public class RabbitMQConfig {
    /**
     * 定义交换机的名/pay_ex
     */
    public static final String EXCHANGE_MAYIKT_NAME = "pay_ex";
    
    /**
     * 微信模板队列
     */
    public static final String MAYIKT_WECHAT_TEMPLATE_QUEUE = "fanout_wechattemplate_queue";
    
    
    /**
     * 缓冲区2条msg
     */
    public static final Integer BUFFER_SIZE =5;
    
    /**
     * 配置微信消息模板队列
     *
     * @return
     */
    @Bean
    public Queue fanoutWechatTemplateQueue() {
        return new Queue(MAYIKT_WECHAT_TEMPLATE_QUEUE);
    }
    
    /**
     * 配置fanoutExchange
     *
     * @return
     */
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange(EXCHANGE_MAYIKT_NAME);
    }
    
    // 绑定交换机 Wechattemplate
    @Bean
    public Binding bindingWechattemplateFanoutExchange(Queue fanoutWechatTemplateQueue, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(fanoutWechatTemplateQueue).to(fanoutExchange);
    }
}
